package com.dataStructure.leetcode.链表;

import com.dataStructure.线性表.链表.LinkedList_双向循环链表;

/**
 *
 */
public class 约瑟夫问题 {
    public static void josephus() {
        LinkedList_双向循环链表<Integer> list = new LinkedList_双向循环链表<>();
        for (int i = 1; i <= 8; i++) {
            list.add(i);
        }
        //指向头结点
        list.reset();
        while (!list.isEmpty()) {
            list.next();
            list.next();
            System.out.println(list.remove());
        }
    }

    public static void main(String[] args) {
        josephus();
    }
}
